package com.mecuros.config;

import com.mecuros.interceptor.FeignAuthRequestInterceptor;
import feign.Contract;
import feign.Logger;
import feign.Request;
import feign.codec.Decoder;
import feign.codec.Encoder;
import feign.form.FormEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Classname OpenFeignConfig
 * @Description TODO
 * @Date 2022/2/9 9:30 下午
 * @Created by yujianbo
 */
@Configuration
public class OpenFeignConfig {

    @Bean
    public Logger.Level feignLoggerLevel(){
        return Logger.Level.FULL;
    }

//    /**
//     * 开启Basic认证
//     * @return
//     */
//    @Bean
//    public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
//        return new BasicAuthRequestInterceptor("fox","123456");
//    }

    /**
     * 自定义拦截器
     * @return
     */
    @Bean
    public FeignAuthRequestInterceptor basicAuthRequestInterceptor() {
        return new FeignAuthRequestInterceptor();
    }

    @Bean
    public Request.Options options() {
        return new Request.Options(5000, 5000);
    }

    @Bean
    public Decoder decoder() {
        return new Decoder.Default();
    }
    @Bean
    public Encoder encoder() {
        return new FormEncoder();
    }

//    /**
//     * 使用Feign原生的注解配置
//     * @return
//     */
//    @Bean
//    public Contract feignContract() {
//        return new Contract.Default();
//    }
}
